
function  chooseChanelProject(){
    var CrmData={
        "customerId":$("#customerId").val(), //项目编码
        "customerCode":$("#customerCode").val(), //项目名称
        "customerName":$("#customerName").val(),//所属分公司
        "belongGroupName":$("#belongGroupName").val(),//所属分公司
    };
    localStorage.setItem("CrmData",JSON.stringify(CrmData));
    layer_show('选择渠道','chooseZjProject.html', 1200, 445);
}

function  chooseProject(){
    var chooseData={
        "projectId":$("#projectId").val(), //项目编码
        "projectName":$("#projectName").val(), //项目名称
        "projectBelongName":$("#projectBelongName").val(),//所属分公司
    };
    localStorage.setItem("chooseData",JSON.stringify(chooseData));
    layer_show('选择渠道','chooseZjProject.html', 1200, 445);
}


//保存
function pircaladd(){
    /*var zhekou=""
    if($("#zhekou").val()==""){
        zhekou="100"
    }else {
        zhekou=$("#zhekou").val()
    }
    if($("input[name=radio1]:checked").val()==""||$("input[name=radio1]:checked").val()==undefined){
        $.Huimodalalert('请选择基础价！',2000);
        return false;
    }
    if($("#zhekou").val()>299 || $("#zhekou").val()< 80){
        $.Huimodalalert('折扣率应在80%-299%范围内！',2000);
        return false;

    }*/

    if (sessionStorage.getItem("id")!=null){
        $.ajax({
            url:root.dockingplatform.updateSubChannelConfigInfo,
            cache: false,  //禁用缓存
            type: "POST",
            dataType:'json',
            contentType: "application/json",
            data: JSON.stringify({
                "id":parseInt(sessionStorage.getItem("id")),
                "parentCustomerCode": sessionStorage.getItem("customerCode"),
                "customerCode": $("#customerCode").val(),
                "projectId": $("#projectId").val(),
                "receiverCompanyName": '',
                "invoiceCompanyName": '',
                "customerId": $("#customerId").val(),
                "customerName": $("#customerName").val(),
                "belongGroupName": $("#belongGroupName").val(),
                "projectName": $("#projectName").val(),
                "projectBelongName": $("#projectBelongName").val()
            }),
            success: function (data) {
                if(data.errorCode==0){
                    showmsg("保存成功",6);
                    //$.Huimodalalert('保存成功！',2000);
                    // var index = parent.layer.getFrameIndex(window.name);
                    // parent.layer.close(index);
                }else {
                    $.Huimodalalert(data.msg,2000);
                }
            },
            error: function () {
                $.Huimodalalert('保存失败！',2000);
            }
        })
    } else {
        $.ajax({
            url:root.dockingplatform.saveSubChannelConfigInfo,
            cache: false,  //禁用缓存
            type: "POST",
            dataType:'json',
            contentType: "application/json",
            data: JSON.stringify({
                "parentCustomerCode": sessionStorage.getItem("customerCode"),
                "customerCode": $("#customerCode").val(),
                "projectId": $("#projectId").val(),
                "receiverCompanyName": '',
                "invoiceCompanyName": '',
                "customerId": $("#customerId").val(),
                "customerName": $("#customerName").val(),
                "belongGroupName": $("#belongGroupName").val(),
                "projectName": $("#projectName").val(),
                "projectBelongName": $("#projectBelongName").val()
            }),
            success: function (data) {
                if(data.errorCode==0){
                    showmsg("保存成功",6);
                    //$.Huimodalalert('保存成功！',2000);
                    /*var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);*/
                }else {
                    $.Huimodalalert(data.msg,2000);
                }
            },
            error: function () {
                $.Huimodalalert('保存失败！',2000);
            }
        })
    }
}

// 提示信息
function showmsg(msg,icon){
    layer.msg(msg, {
        icon:icon,
        time: 1000
    },function(){
        if(icon==6){
            var index = parent.location.reload();
            parent.layer.close(index);
        }
    });
}
